/*   1:    */ package tt.dz.web.controller.common;
/*   2:    */ 
/*   3:    */ import com.alibaba.fastjson.JSON;
/*   4:    */ import com.alibaba.fastjson.serializer.SerializerFeature;
/*   5:    */ import java.util.HashMap;
/*   6:    */ import java.util.Iterator;
/*   7:    */ import java.util.List;
/*   8:    */ import java.util.Map;
/*   9:    */ import javax.annotation.Resource;
/*  10:    */ import org.springframework.stereotype.Controller;
/*  11:    */ import org.springframework.web.bind.annotation.RequestMapping;
/*  12:    */ import org.springframework.web.bind.annotation.ResponseBody;
/*  13:    */ import tt.dz.biz.service.common.CommonService;
/*  14:    */ import tt.dz.common.LogUtil;
/*  15:    */ import tt.dz.vo.CityVO;
/*  16:    */ import tt.dz.vo.CountryVO;
/*  17:    */ import tt.dz.vo.DistrictVO;
/*  18:    */ import tt.dz.vo.ProvinceVO;
/*  19:    */ import tt.dz.vo.ResponseModle;
/*  20:    */ 
/*  21:    */ @Controller
/*  22:    */ public class CommonController
/*  23:    */ {
/*  24:    */   @Resource(name="commonService")
/*  25:    */   private CommonService commonService;
/*  26:    */   
/*  27:    */   @RequestMapping(value={"/listAllCountry"}, produces={"application/json;charset=UTF-8"})
/*  28:    */   @ResponseBody
/*  29:    */   public String listAllCountry()
/*  30:    */   {
/*  31: 37 */     ResponseModle responseModle = null;
/*  32:    */     try
/*  33:    */     {
/*  34: 39 */       List<CountryVO> countryList = this.commonService.listAllCountry();
/*  35: 40 */       Iterator<CountryVO> iterator = countryList.iterator();
/*  36: 41 */       CountryVO sourceCountry = null;
/*  37: 42 */       Map<String, Object> resultMap = new HashMap();
/*  38: 43 */       while (iterator.hasNext())
/*  39:    */       {
/*  40: 44 */         sourceCountry = (CountryVO)iterator.next();
/*  41: 45 */         resultMap.put(sourceCountry.getCountryCode(), sourceCountry);
/*  42:    */       }
/*  43: 47 */       responseModle = new ResponseModle("success", resultMap);
/*  44:    */     }
/*  45:    */     catch (Exception e)
/*  46:    */     {
/*  47: 49 */       LogUtil.error("查询国家异常", e);
/*  48: 50 */       responseModle = new ResponseModle("error", new HashMap());
/*  49:    */     }
/*  50: 52 */     return JSON.toJSONString(responseModle);
/*  51:    */   }
/*  52:    */   
/*  53:    */   @RequestMapping(value={"/listAllProvince"}, produces={"application/json;charset=UTF-8"})
/*  54:    */   @ResponseBody
/*  55:    */   public String listAllProvince()
/*  56:    */   {
/*  57: 61 */     ResponseModle responseModle = null;
/*  58:    */     try
/*  59:    */     {
/*  60: 63 */       List<ProvinceVO> provinceList = this.commonService.listAllProvince();
/*  61: 64 */       Iterator<ProvinceVO> iterator = provinceList.iterator();
/*  62: 65 */       ProvinceVO sourceProvince = null;
/*  63: 66 */       Map<String, Object> resultMap = new HashMap();
/*  64: 67 */       while (iterator.hasNext())
/*  65:    */       {
/*  66: 68 */         sourceProvince = (ProvinceVO)iterator.next();
/*  67: 69 */         resultMap.put(sourceProvince.getProvinceCode(), sourceProvince);
/*  68:    */       }
/*  69: 71 */       responseModle = new ResponseModle("success", resultMap);
/*  70:    */     }
/*  71:    */     catch (Exception e)
/*  72:    */     {
/*  73: 73 */       LogUtil.error("查询省/直辖市异常", e);
/*  74: 74 */       responseModle = new ResponseModle("error", new HashMap());
/*  75:    */     }
/*  76: 76 */     return JSON.toJSONString(responseModle, new SerializerFeature[] { SerializerFeature.DisableCircularReferenceDetect });
/*  77:    */   }
/*  78:    */   
/*  79:    */   @RequestMapping(value={"/listAllCity"}, produces={"application/json;charset=UTF-8"})
/*  80:    */   @ResponseBody
/*  81:    */   public String listAllCity()
/*  82:    */   {
/*  83: 85 */     ResponseModle responseModle = null;
/*  84:    */     try
/*  85:    */     {
/*  86: 87 */       List<CityVO> cityList = this.commonService.listAllCity();
/*  87: 88 */       Iterator<CityVO> iterator = cityList.iterator();
/*  88: 89 */       CityVO sourceCity = null;
/*  89: 90 */       Map<String, Object> resultMap = new HashMap();
/*  90: 91 */       while (iterator.hasNext())
/*  91:    */       {
/*  92: 92 */         sourceCity = (CityVO)iterator.next();
/*  93: 93 */         resultMap.put(sourceCity.getCityCode(), sourceCity);
/*  94:    */       }
/*  95: 95 */       responseModle = new ResponseModle("success", resultMap);
/*  96:    */     }
/*  97:    */     catch (Exception e)
/*  98:    */     {
/*  99: 97 */       LogUtil.error("查询城市异常", e);
/* 100: 98 */       responseModle = new ResponseModle("error", new HashMap());
/* 101:    */     }
/* 102:100 */     return JSON.toJSONString(responseModle, new SerializerFeature[] { SerializerFeature.DisableCircularReferenceDetect });
/* 103:    */   }
/* 104:    */   
/* 105:    */   @RequestMapping(value={"/listAllDistrict"}, produces={"application/json;charset=UTF-8"})
/* 106:    */   @ResponseBody
/* 107:    */   public String listAllDistrict()
/* 108:    */   {
/* 109:109 */     ResponseModle responseModle = null;
/* 110:    */     try
/* 111:    */     {
/* 112:111 */       List<DistrictVO> districtList = this.commonService.listAllDistrict();
/* 113:112 */       Iterator<DistrictVO> iterator = districtList.iterator();
/* 114:113 */       DistrictVO sourceDistrict = null;
/* 115:114 */       Map<String, Object> resultMap = new HashMap();
/* 116:115 */       while (iterator.hasNext())
/* 117:    */       {
/* 118:116 */         sourceDistrict = (DistrictVO)iterator.next();
/* 119:117 */         resultMap.put(sourceDistrict.getDistrictCode(), sourceDistrict);
/* 120:    */       }
/* 121:119 */       responseModle = new ResponseModle("success", resultMap);
/* 122:    */     }
/* 123:    */     catch (Exception e)
/* 124:    */     {
/* 125:121 */       LogUtil.error("查询区/县异常", e);
/* 126:122 */       responseModle = new ResponseModle("error", new HashMap());
/* 127:    */     }
/* 128:124 */     return JSON.toJSONString(responseModle, new SerializerFeature[] { SerializerFeature.DisableCircularReferenceDetect });
/* 129:    */   }
/* 130:    */ }


/* Location:           F:\work\pengyu\mainServer\WEB-INF\classes\
 * Qualified Name:     tt.dz.web.controller.common.CommonController
 * JD-Core Version:    0.7.0.1
 */